<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <!--头部固定引用-->
  <meta charset="utf-8">
  <meta name="full-screen" content="yes">
  <meta name="x5-fullscreen" content="true">
  <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
  <link rel="stylesheet" href="../../css/base.css">
  <!--固定引用结束,自定义引用添加在下面-->
  <title>话题详情</title>
  <!--页面样式添加在这里，多看看base。css里面的公共样式，大部分常用的都有，避免使用独立css文件为单独页面设置样式，避免随意添加样式到公共样式-->
  <style>
      body {
        height: auto;
      }
      .topicdetails-header {
        padding:0.22rem 0.32rem 0.26rem;
        background-image: url(../../images/allPic/huatibgc.png);
        height: 4.48rem;
        position: fixed;
        top: 0;
        width: 100%;
        z-index: 1;
      }
      .toptitle {
        font-family: PingFangSC-Medium;
        font-size: 0.32rem;
        color: #fff;
        letter-spacing: 0;
        text-align: center;
        position: relative;
        margin-bottom: 0.14rem;
      }
      .topicdetails-header .toptitle-img {
          width: 0.32rem;
          height: 0.32rem;
          position: absolute;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
      }
      .topictitle {
          margin-top: 0.58rem;
          color: #fff;
          line-height: 0.44rem;
          margin-bottom: 0.08rem;
      }
      .topictitle .span1{
        display: inline-block;
        font-family: Helvetica;
        font-size: 0.34rem;
        font-weight: 700;
        color: #FFFFFF;
        letter-spacing: 0;
        text-align: left;
        margin-right: 0.12rem;
        vertical-align: middle;
        text-overflow: -o-ellipsis-lastline;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp:2;
        -webkit-box-orient: vertical;
      }
      .topictitle .span2{
        display: inline-block;
        background-image: linear-gradient(137deg, #EF7B40 0%, #E84B4A 100%);
        border-radius: 2px;
        width: 0.74rem;
        height: 0.34rem;
        line-height: 0.34rem;
        text-align: center;
        vertical-align: middle;
        font-family: PingFangSC-Regular;
        font-size: 0.24rem;
        color: #FFFFFF;
      }
      .topichost {
        line-height: 0.34rem;
        height: 0.34rem;
        opacity: 0.88;
        font-family: PingFangSC-Regular;
        font-size: 0.24rem;
        color: #FFFFFF;
        letter-spacing: 0;
        text-align: left;
        margin-bottom: 0.26rem;
      }
      .topicOprate {
          display: flex;
          justify-content: space-around;
          align-items: center;
          height: 0.8rem;
          line-height: 0.8rem;
          background: #7F6A67;
          border-radius: 0.08rem;
          margin-bottom: 0.2rem;
          margin-top: 0.6rem;
      }
      .topicOprate .flexbox{
        font-family: PingFangSC-Regular;
        font-size: 0.24rem;
        color: #FFFFFF;
        letter-spacing: 0;
        text-align: left;
      }
      .topicOprate .flexbox img {
          vertical-align: middle;
          width: 0.36rem;
          height: 0.36rem;
      }
      .topicOprate .flexbox .flexspan {
          margin-right: 0.08rem;
          vertical-align: middle;
      }
      .flexspan1 {
        vertical-align: middle;
      }
      .topicContent-detail {
        padding-bottom: 1.02rem;
      }
      .topicContent-detail ul {
        list-style: none;
        margin: 0;
        padding: 0;
      }
      .topicContent-detail ul {
        /* border-bottom: 0.02rem solid #f7f7f7; */
      }
      .topicContent-detail ul li:last-child::after{
        height: 0;
      }
      .topicContent-detail-top {
        position: relative;
        height: 0.98rem;
      }
      .top-imgbox {
        position: absolute;
        left: 0;
        top: 0;
        width: 0.68rem;
        height: 0.68rem;
        border-radius: 50%;
      }
      .top-imgbox img {
        width: 0.68rem;
        height: 0.68rem;
        border-radius: 50%;
      }
      .top-explain {
        position: absolute;
        left: 0.88rem;
        top: 0;
      }

      .topicContent-detail-content {
        /* padding-top: 0.34rem; */
        padding-left: 0.88rem;
      }
      .topicContent-detail-bottom {
        position: relative;
        height: 0.4rem;
      }
      .topicContent-detail-bottom img {
        vertical-align: middle;
        margin-right: 0.09rem;
      }
      .bottom-imgbox1 {
        position: absolute;
        top: 0;
        right: 0;
      }
      .bottom-imgbox1 .dzspan{
        margin-right: 0.2rem;
      }
      .topicdetails-footer-imgBox {
          position: relative;
          display: inline-block;
          vertical-align: middle;
          margin-right: 0.4rem;
      }
      .topicdetails-footer-imgBox img {
          width: 0.36rem;
          height: 0.36rem;
      }
      .topicdetails-footer-imgBox span{
        position: absolute;
        right: -0.24rem;
        top: -0.18rem;
        font-family: PingFangSC-Regular;
        font-size: 0.22rem;
        color: #FFFFFF;
        width: 0.38rem;
        height: 0.24rem;
        text-align: center;
        background: #EF4244;
        border-radius: 0.12rem;
        line-height: 0.24rem;
        text-align: center;
      }
      .topicdetails-footer-imgBox .shafa{
        height: 0.3rem;
        line-height: 0.3rem;
        width: 0.8rem;
        right: -0.6rem;
      }

      .commentmain-no-img {
          padding-top: 1.08rem;
          margin-bottom: 0.52rem;
          text-align: center;
      }
      .commentmain-no-img  img {
          width: 2.36rem;
          height: 1.42rem;
      }
      .commentmain-no-text {
        text-align: center;
        padding-bottom: 3.42rem;
      }

      .footer-noconfirm {
        display: block;
      }
      .footer-confirm {
        display: none;
      }
      .tpimg {
        vertical-align: middle;
        width: 0.32rem;
        height: 0.32rem;
      }
      .secondcomment-seeAll {
          padding-top: 0.2rem;
          height: 0.54rem;
          margin-left: 1.46rem;
      }
      .secondcomment-seeAll span{
        font-family: PingFangSC-Regular;
        font-size: 0.24rem;
        color: #CF222C;
        line-height: 0.34rem;
      }
      /*  */
  .topicContent {
    margin-top: 4.48rem;
  }
  .topicContent-explain {
    padding: 0 0.32rem;
    border-radius: 0.16rem 0.16rem 0 0;
  }
  .topicContent-explain-top {
    font-family: PingFangSC-Medium;
    font-size: 0.3rem;
    line-height: 0.42rem;
    padding-top: 0.4rem;
    padding-bottom: 0.3rem;
  }
  .topicContent-explain-subtitle {
    line-height: 1.02rem;
    font-family: PingFangSC-Regular;
    font-size: 0.3rem;
  }
  .topicContent-detail ul li{
    padding: 0.3rem 0.34rem 0.32rem 0.32rem;
    position: relative;
  }
  .topicContent-detail ul li::after{
    width: 100%;
    height: 0.14rem;
    content: '';
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
  }
  .topicContent-detail-top .comstatus {
    position: absolute;
    right: 0;
    top: 0;
    font-size: 0.24rem;
    font-weight: 400;
  }
  .top-explain .explain1{
    font-family: PingFangSC-Semibold;
    font-size: 0.28rem;
    line-height: 0.4rem;
    margin-bottom: 0.02rem;
  }
  .top-explain .explain2{
    font-family: PingFangSC-Regular;
    font-size: 0.24rem;
    line-height: 0.34rem;
  }
  .topicContent-detail-content p{
    word-break:break-all;
    word-wrap:break-word;
    font-family: PingFangSC-Regular;
    font-size: 0.32rem;
    line-height: 0.44rem;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6;
    overflow: hidden;
    margin: 0;
  }
  .topicdetails-footer {
    padding: 0.2rem 0 0.2rem 0.32rem;
    position: fixed;
    bottom: 0;
    z-index: 1;
    width: 100%;
}
.topicdetails-footer input{
  width: 5.04rem;
  height: 0.6rem;
  padding: 0.12rem 0 0.12rem 0.28rem;
  font-family: PingFangSC-Regular;
  font-size: 0.26rem;
  margin-right: 0.4rem;
}
.commentmain-no{
}
.commentmain-no-text span{
  font-family: PingFangSC-Regular;
  font-size: 0.28rem;
  line-height: 0.44rem;
}
  </style>
</head>
<!--尽量不要在body上添加样式，除了背景色-->
<body>
<div>
    <!--具体代码-->
    <!-- 头部 -->
    <div class="topicdetails-header">
      <div class="seatBox"></div>
      <div class="titleBox"></div>
    </div>

    <!-- 内容 -->
    <div class="topicContent">
        <div class="topicContent-explain">
        </div>
    </div>
    <!-- 内容主体 -->
    <div class="topicContent-detail">
      <ul>
      </ul>

    </div>

    <!-- 底部输入框 -->
    <div class="topicdetails-footer">
      <input type="text" placeholder="请说说你的看法..." class="commentInpt">
      <div style='display:inline-block;' class="mainfooter">
    </div>

</div>

</body>
<!--下面五个文件为固定引用，自己根据情况调整路径，不要跟换引入顺序，其他引用添加在后面-->
<script src="../../js/dict.js"></script>
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/checkJsBridge.js"></script>
<script src="../../js/utils.js"></script>
<script src="../../js/api.js"></script>
<!--固定引用结束-->
<!--避免一个页面包含过多功能，减少js重绘页面，推荐分功能，分页面-->
<script>
  //commentObjectId就是infoId
  let commentObjectId
  let isopencomment
  let token
  let pageNum = 1
  //区别是从原生跳转还是H5跳转
  let isorign
  /*固定页面初始化方法，用于替代$(function(){}),param为url参数，Object类型*/
  function initPage(params) {
    commentObjectId = params.infoId
    isopencomment = params.isopencomment?params.isopencomment:'0'

    jsBridge.setWebFullScreen({'statusNumber':'1'})


    $('.seatBox').height(configHeight+'rem')
    //设置深色模式
    // if(configColorType === '1'){
    //     $('.headerimg').attr('src','../../images/allPic/blackfanhui.png')
    // }else{
    //     $('.headerimg').attr('src','../../images/allPic/jiantou.png')
    // }

    if(!params.isorign){
      isorign = '0'
    }else{
      isorign = params.isorign
    }

    console.log(params)

    //页面加载获取token用于判断是否可以评论或者点赞
    jsBridge.getData('token').then(res => {
      console.log(res)
      token = res
    })

    $('.topicContent-detail ul').empty()
    //判断二级列表页面的参数isopencomment是否唤起评论框
    if(params.isopencomment === '1'){
      isopencomment = '0'
      Details(params.infoId)
      getComment({'InfoId':params.infoId,'pageNum':pageNum})


    }else{
      isopencomment = '0'
      Details(params.infoId)
      getComment({'InfoId':params.infoId,'pageNum':pageNum})
    }
  }

  /*页面所在窗口由后台前台时触发的方法,param为url参数，Object类型*/
  function startPage(params) {

  }

  function reLoadPage() {
    jsBridge.getData('token').then(res => {
      console.log(res)
      token = res
    })
    $('.topicContent-detail ul').empty()
    Details(commentObjectId)
    getComment({'InfoId':commentObjectId,'pageNum':1})
  }
  //获取互动详情
  function Details(params){
    Server.InteractionDDetails.getDetails({'infoId':params}).then(res => {
      console.log(res)

      $('.titleBox').empty()
      $('.topicContent-explain').empty()
      $('.mainfooter').empty()
      if(res.code === 0){
        //刷新上级H5页面的阅读数
        jsBridge.updateStatus({'type':'refresh','name':'refresh','infoId':commentObjectId,'value':'1'})
        //刷新原生页面的阅读数
        let readCount = res.detail.readCnt
        jsBridge.updateStatus({'type':'hudong','name':'read','infoId':commentObjectId,'value':readCount})
        //刷新原生页面的评论数
        let commenCount = res.detail.participantsCnt
        jsBridge.updateStatus({'type':'hudong','name':'comm','infoId':commentObjectId,'value':commenCount})

        let detail = res.detail
        //修改时间戳
        let creatTime = detail.issuerDttm*1000
        let nowTime = +new Date().valueOf()
        let year = new Date(creatTime).getFullYear()
        let month = new Date(creatTime).getMonth()+1<10?'0'+(new Date(creatTime).getMonth()+1):new Date(creatTime).getMonth()+1
        let day = new Date(creatTime).getDate()<10?'0'+new Date(creatTime).getDate():new Date(creatTime).getDate()
        let hour = new Date(creatTime).getHours()<10?'0'+ new Date(creatTime).getHours(): new Date(creatTime).getHours()
        let minute = new Date(creatTime).getMinutes()<10?'0'+new Date(creatTime).getMinutes():new Date(creatTime).getMinutes()
        if(nowTime - creatTime < 30*60*1000){
          if(nowTime - creatTime < 1*60*1000){
            detail.issuerDttm = '刚刚'
          }else{
            detail.issuerDttm = parseInt((nowTime - creatTime)/1000/60)+'分钟前'
          }
        }else if(nowTime - creatTime < 24*60*60*1000){
            if(nowTime-creatTime < 60*60*1000){
              detail.issuerDttm = '1小时前'
            }else {
              detail.issuerDttm = parseInt((nowTime - creatTime)/1000/60/60)+'小时前'
            }
        }else if(new Date().getDate()-new Date(creatTime).getDate()==1 && new Date().getMonth()==new Date(creatTime).getMonth() && new Date().getFullYear() == new Date(creatTime).getFullYear()){
          detail.issuerDttm = '昨天'+hour+":"+minute
        }else{
          detail.issuerDttm =year+'-'+ month+'-'+day+' '+hour+':'+minute
        }

        let top =
        `<div class="toptitle">
            <img src="../../images/allPic/baijiantou.png" alt="" class="toptitle-img" onclick="closeWindow()">
            <span>话题详情</span>
        </div>
        <div class="topictitle">
                <span class="span1">${detail.mainTitle}</span>
                <span class="span2">热门</span>
            </div>
            <div class="topichost" style='display:none'>
                <span style="display:${isorign ==='0'?'none':'block'}">主持人：</span><span style="display:${isorign ==='0'?'none':'block'}">${detail.owner?detail.owner:''}</span>
            </div>
            <div class="topicOprate">
                <div class="flexbox">
                    <img src="../../images/allPic/topictl.png" alt="">
                    <span class="flexspan">讨论</span><span class='flexspan1'>${detail.participantsCnt}</span>
                </div>
                <div class="flexbox">
                    <img src="../../images/allPic/topicdz.png" alt="">
                    <span class="flexspan">点赞</span><span class='flexspan1'>${detail.thumbsupCnt}</span>
                </div>
            </div>`

            let content =
                `<div class="topicContent-explain-top">
                    <span>${detail.interactionIntroduce}</span>
                </div>
                <div class="topicContent-explain-subtitle">
                    <span>话题参与</span>
                </div>`

          let footer =
            `<div class="footer-noconfirm" id='footer-noconfirm'  style="display:${isopencomment==='0'?'block':'none'}">
                <div class="topicdetails-footer-imgBox" onclick="picComment()">
                  <img src="${configColorType==='1'?'../../images/allPic/blackpinglun.png':'../../images/allPic/dapinglun.png'}" alt="">
                  <span style="display:${detail.participantsCnt===0?'block':'none'}" class='shafa'>抢沙发</span>
                  <span style="display:${detail.participantsCnt===0?'none':'block'}">${detail.participantsCnt}</span>
                </div>
                <div class="topicdetails-footer-imgBox" >
                    <div style='display:inline-block;'>
                      <img src="${configColorType==='1'?'../../images/allPic/blackdianzan.png':'../../images/allPic/danodianzan.png'}" alt="" data-status='1' onclick="ftpriase({'status':'${detail.thumbsupStatus==='0'?'1':'0'}','thumbupObjectId':'${detail.infoId}'},this)" style="display:${detail.thumbsupStatus === '1'?'none':'block'}">
                      <img src="../../images/allPic/dayidianzan.png" alt="" data-status='0' onclick="ftpriase({'status':'${detail.thumbsupStatus==='1'?'0':'1'}','thumbupObjectId':'${detail.infoId}'},this)" style="display:${detail.thumbsupStatus === '1'?'block':'none'}">
                    </div>
                    <span style="display:${detail.thumbsupCnt===0?'none':'block'}">${detail.thumbsupCnt}</span>
                </div>
              </div>
              <div class="footer-confirm" id='footer-confirm' onclick="sendcomment({'participantsCnt':'${detail.participantsCnt}'})"  style="display:${isopencomment==='0'?'none':'block'};padding-left:0.4rem;">发送</div>`

          $('.titleBox').append(top)
          $('.topicContent-explain').append(content)
          $('.mainfooter').append(footer)
      }else{
        // jsBridge.toast('数据异常')
      }
    })
  }
  //获取互动详情的评论
  function getComment(params){
    Server.InteractionDDetailsComment.getcomment({'InfoId':params.InfoId,"pageSize":10,"pageNum":params.pageNum}).then(res =>{
      console.log(res)
      if(res.code === 0){
        let list = res.list
        //分为有评论和无评论
        if(list.length === 0 && pageNum === 1){
          let comment =
              `<div class="commentmain-no">
                  <div class="commentmain-no-img">
                      <img src="../../images/allPic/zanwu.png" alt="">
                  </div>
                  <div class="commentmain-no-text">
                      <span>还没有评论，快来抢沙发～</span>
                  </div>
              </div>`
          $('.topicContent-detail').append(comment)
        }else{
            list.map((item,index) => {
              let creatTime = item.createDttm*1000
              let nowTime = +new Date().valueOf()
              let year = new Date(creatTime).getFullYear()
              let month = new Date(creatTime).getMonth()+1<10?'0'+(new Date(creatTime).getMonth()+1):new Date(creatTime).getMonth()+1
              let day = new Date(creatTime).getDate()<10?'0'+new Date(creatTime).getDate():new Date(creatTime).getDate()
              let hour = new Date(creatTime).getHours()<10?'0'+ new Date(creatTime).getHours(): new Date(creatTime).getHours()
              let minute = new Date(creatTime).getMinutes()<10?'0'+new Date(creatTime).getMinutes():new Date(creatTime).getMinutes()
              if(nowTime - creatTime < 30*60*1000){
                if(nowTime - creatTime < 1*60*1000){
                  item.createDttm = '刚刚'
                }else{
                  item.createDttm = parseInt((nowTime - creatTime)/1000/60)+'分钟前'
                }
              }else if(nowTime - creatTime < 24*60*60*1000){
                  if(nowTime-creatTime < 60*60*1000){
                    item.createDttm = '1小时前'
                  }else {
                    item.createDttm = parseInt((nowTime - creatTime)/1000/60/60)+'小时前'
                  }
              }else if(new Date().getDate()-new Date(creatTime).getDate()==1 && new Date().getMonth()==new Date(creatTime).getMonth() && new Date().getFullYear() == new Date(creatTime).getFullYear()){
                item.createDttm = '昨天'+hour+":"+minute
              }else{
                item.createDttm =year+'-'+ month+'-'+day+' '+hour+':'+minute
              }
          })

          list.map((item,index) => {
            let li =
            `<li onclick="gocomment({'datasource':'1','isopencomment':'0','parentId':'${item.commentId}','commentObjectId':'${commentObjectId}','status':'${item.status}'})">
                <div class="topicContent-detail-top">
                  <div class='comstatus' style="display:${item.status==='2'?'block':'none'}">审核中</div>
                  <div class="top-imgbox">
                    <img src="${item.headUrl?item.headUrl:'../../images/allPic/touxiang.png'}" alt="">
                  </div>
                  <div class="top-explain">
                    <div class="explain1">${item.userName}</div>
                    <div class="explain2">${item.createDttm}</div>
                  </div>
                </div>
                <div class="topicContent-detail-content">
                  <p>${item.content}</p>
                </div>

                <div class="secondcomment-seeAll" style="display:${(item.childCount !== 0 && item.status === '1')?'block':'none'}">
                  <span onclick="dosecondcomment({'datasource':'1','isopencomment':'0','parentId':'${item.commentId}','commentObjectId':'${commentObjectId}'})">查看全部评论(${item.childCount})条></span>
                </div>

                <div class="topicContent-detail-bottom" style="display:${item.status==='2'?'none':'block'}">
                  <div class="bottom-imgbox1">
                    <div style='display:inline-block;vertical-align:middle;'>
                      <img src="${configColorType ==='1'?'../../images/allPic/blackdianzan.png':'../../images/allPic/nodianzan1.png'}" alt="" data-status='1' style="display:${item.thumbsupStatus === '1'?'none':'block'};" onclick="priase({'status':'${item.thumbsupStatus==='0'?'1':'0'}','thumbupObjectId':'${item.commentId}'},this)" class='tpimg'>
                      <img src="../../images/allPic/yidianzan1.png" alt="" data-status='0' style="display:${item.thumbsupStatus === '1'?'block':'none'};" onclick="priase({'status':'${item.thumbsupStatus==='1'?'0':'1'}','thumbupObjectId':'${item.commentId}'},this)" class='tpimg'>
                    </div>
                    <span class='dzspan' style='vertical-align:middle;'>${item.thumbsupCnt}</span>
                    <img src="${configColorType==='1'?'../../images/allPic/blackpinglun.png':'../../images/allPic/xiaopinglu1.png'}" alt="" onclick="dosecondcomment({'datasource':'1','isopencomment':'1','parentId':'${item.commentId}','commentObjectId':'${commentObjectId}'})" class='tpimg'>
                    <span style='vertical-align:middle;'>${item.childCount}</span>
                  </div>
                </div>
              </li>`
            $('.topicContent-detail ul').append(li)
          })
        }

      }else{
        // jsBridge.toast('数据异常')
      }
    })
  }
//从互动页面跳转过来的评论
function dofirstcomment(){

}
//从互动详情页的评论点击回复做二级评论,唤起输入框
function dosecondcomment(params){
  // console.log(params)
  if(token){
    jsBridge.openWindow('/html/comment/commentdetails.html?parentId='+params.parentId+'&datasource=1'+'&isopencomment='+params.isopencomment+'&commentObjectId='+params.commentObjectId,{}, {noBar: false})
  }else{
    // jsBridge.toast('暂未登录,请先登录...')
    jsBridge.openLogin()
  }
}
//去评论详情页但是不换起输入框
function gocomment(params){
  // console.log(params)
  // if(params.status === '2'){
  //   return false
  // }else{
  //   if(token){
  //     jsBridge.openWindow('/html/comment/commentdetails.html?parentId='+params.parentId+'&datasource=1'+'&isopencomment='+params.isopencomment+'&commentObjectId='+params.commentObjectId,{}, {noBar: false})
  //   }else{
  //     // jsBridge.toast('暂未登录,请先登录...')
  //     jsBridge.openLogin()
  //   }
  // }
  if(token){
    jsBridge.openWindow('/html/comment/commentdetails.html?parentId='+params.parentId+'&datasource=1'+'&isopencomment='+params.isopencomment+'&commentObjectId='+params.commentObjectId,{}, {noBar: false})
  }else{
    // jsBridge.toast('暂未登录,请先登录...')
    jsBridge.openLogin()
  }
  // console.log(111)
}
//input框聚焦失焦,加定时器确保点击事件先触发
$('.commentInpt').blur(function(){
  setTimeout(function(){
    $('#footer-noconfirm').show()
    $('#footer-confirm').hide()
  },100)
})
$('.commentInpt').focus(function(){
  setTimeout(function(){
    $('#footer-noconfirm').hide()
    $('#footer-confirm').show()
  },100)
})
//点击发送增加一级评论
function sendcomment(params){
  if(token){
    let content = $('.commentInpt').val()
    if(content === ''){
      jsBridge.toast('内容不为空')
    }else{
      Server.InteractionDDetailsComment.addComment({commentInfo:{'parentId':'0','commentObjectId':commentObjectId,'content':content,'datasource':'1'}}).then(res => {
        console.log(res)
        if(res.code === 0){
           //同步原生页面的评论数
           jsBridge.updateStatus({'type':'hudong','name':'comm','infoId':commentObjectId,'value':+params.participantsCnt+1})
          //同步上一级页面刷新
          jsBridge.updateStatus({'type':'refresh','name':'refresh','infoId':commentObjectId,'value':'1'})
          // jsBridge.toast('评论成功')
          $('.commentInpt').val('')
          $('.topicContent-detail ul').empty()
          $('.commentmain-no').hide()
            pageNum = 1
            getComment({'InfoId':commentObjectId,'pageNum':pageNum})
            Details(commentObjectId)
            $('.commentInpt').blur()
        }else{
          // jsBridge.toast('数据异常')
        }
      })
    }
  }else{
    // jsBridge.toast('暂未登录,请先登录...')
    jsBridge.openLogin()
  }
}
//点击评论小图标做一级评论
function picComment(){
  $('.commentInpt').focus()
}
//点击评论的点赞按钮
function priase(params1,params2){
    event.stopPropagation()
    // console.log(params1,params2)
    if(token){
        let status = $(params2).attr('data-status')
        if(status === '1'){
          let num = $(params2).parent().next().text()
          $(params2).parent().next().text(+num+1)
        }else{
          let num = $(params2).parent().next().text()
          $(params2).parent().next().text(+num-1)
        }
        $(params2).hide().siblings().show()
        Server.InteractionPriase.updatePriase({thumbup:{'status':status,'thumbupObjectId':params1.thumbupObjectId,'datasource':1,'objectSource':'6'}}).then(res => {
        console.log(res)
        if(res.code === 0){
          //切换点赞状态并且重新请求数据

          // $('.topicContent-detail ul').empty()
          // pageNum = 1
          // getComment({'InfoId':commentObjectId,'pageNum':pageNum})
        }else{
          // jsBridge.toast(res.msg)
        }
      })
    }else{
      // jsBridge.toast('暂未登录,请先登录')
      jsBridge.openLogin()
    }
  }
//点击底部的点赞按钮
function ftpriase(params1,params2){
    console.log(params1,params2)
    event.stopPropagation()
    if(token){
      let status = $(params2).attr('data-status')
      if(status === '1'){
        let num = $(params2).parent().next().text()
        if(num === '0'){
          $(params2).parent().next().show()
          $(params2).parent().next().text(+num+1)
        }else{
          $(params2).parent().next().text(+num+1)
        }
        //刷新原生页面的点赞状态
        let ysNum = +num + 1
        jsBridge.updateStatus({'type':'hudong','name':'zanjia','infoId':commentObjectId,'value':ysNum})
      }else{
        let num = $(params2).parent().next().text()
        $(params2).parent().next().text(+num-1)
        if($(params2).parent().next().text() === '0'){
          $(params2).parent().next().hide()
        }
        //刷新原生页面的点赞状态
        let ysNum = +num - 1
        jsBridge.updateStatus({'type':'hudong','name':'zanjian','infoId':commentObjectId,'value':ysNum})
      }
      $(params2).hide().siblings().show()
      Server.InteractionPriase.updatePriase({thumbup:{'status':status,'thumbupObjectId':params1.thumbupObjectId,'datasource':1,'objectSource':'4'}}).then(res => {
        console.log(res,'update')
        if(res.code === 0){
          //同步上一级页面刷新
          jsBridge.updateStatus({'type':'refresh','name':'refresh','infoId':'','value':'1'})
          // //切换图片状态并且重新获取数据
          // $(params2).hide().siblings().show()
          // Details(commentObjectId)
        }else{
          // jsBridge.toast(res.msg)
        }
      })
    }else{
      // jsBridge.toast('暂未登录,请先登录...')
      jsBridge.openLogin()
    }
  }
  //点击返回按钮
  function closeWindow(){
    jsBridge.closeWindows()
  }
  //滑动加载下一页
  document.addEventListener('scroll',function(){
    let top = $('.topicContent-detail').offset().top
    let height = $('.topicContent-detail').outerHeight(true)
    let maxHeight = document.body.offsetHeight
    let scroll = $(document).scrollTop()
    // console.log(scroll,'scroll')
    // console.log(top,'top')
    // console.log(height,'height')
    // console.log(maxHeight,'maxHeight')
    // console.log(top+height+51-maxHeight,'top+height-maxHeight')
    if(Math.round(top+height-maxHeight) === Math.round(scroll) ){
      pageNum++
      getComment({'pageNum':pageNum,'InfoId':commentObjectId})
    }
  })
</script>
</html>
